<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    54. Spiral Matrix
   </h1>
   <p>
    Given a matrix of
    <em>
     m
    </em>
    x
    <em>
     n
    </em>
    elements (
    <em>
     m
    </em>
    rows,
    <em>
     n
    </em>
    columns), return all elements of the matrix in spiral order.
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong>
[
 [ 1, 2, 3 ],
 [ 4, 5, 6 ],
 [ 7, 8, 9 ]
]
<strong>Output:</strong> [1,2,3,6,9,8,7,4,5]
</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong>
[
  [1, 2, 3, 4],
  [5, 6, 7, 8],
  [9,10,11,12]
]
<strong>Output:</strong> [1,2,3,4,8,12,11,10,9,5,6,7]
</pre>
  </div>
  <div>
   <h1 class="question_title">
    54. 螺旋矩阵
   </h1>
   <p>
    给定一个包含&nbsp;
    <em>
     m
    </em>
    x
    <em>
     n
    </em>
    &nbsp;个元素的矩阵（
    <em>
     m
    </em>
    行,
    <em>
     n
    </em>
    列），请按照顺时针螺旋顺序，返回矩阵中的所有元素。
   </p>
   <p>
    <strong>
     示例&nbsp;1:
    </strong>
   </p>
   <pre><strong>输入:</strong>
[
 [ 1, 2, 3 ],
 [ 4, 5, 6 ],
 [ 7, 8, 9 ]
]
<strong>输出:</strong> [1,2,3,6,9,8,7,4,5]
</pre>
   <p>
    <strong>
     示例&nbsp;2:
    </strong>
   </p>
   <pre><strong>输入:</strong>
[
  [1, 2, 3, 4],
  [5, 6, 7, 8],
  [9,10,11,12]
]
<strong>输出:</strong> [1,2,3,4,8,12,11,10,9,5,6,7]
</pre>
  </div>
 </body>
</html>